package com.example.g7640.convert;

import com.example.g7640.dto.OrderDetailDto;
import com.example.g7640.dto.OrderDto;
import com.example.g7640.entity.Order;
import com.example.g7640.entity.OrderDetail;
import com.example.g7640.util.BaseConvertor;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

@Component
public class OrderConvertor {

    public OrderDto doToDto(Order order, List<OrderDetail> detailList){
        OrderDto orderDto = new OrderDto();
        orderDto.setId(order.getId());
        orderDto.setCid(order.getCid());
        orderDto.setStatus(order.getStatus());
        orderDto.setDate(order.getDate());
        orderDto.setDetailList(BaseConvertor.convertList(detailList, OrderDetailDto.class));
        return orderDto;
    }


}
